#!/bin/bash

# 打印logo和描述信息
logo=$(cat <<'EOF'
   _____                                  _   _             _
 / ____|                                | | | |           | |
| (___   ___ _ ____   _____ _ __    __ _| |_| |_ __ _  ___| | __
 \___ \ / _ \ '__\ \ / / _ \ '__|  / _` | __| __/ _` |/ __| |/ /
 ____) |  __/ |   \ V /  __/ |    | (_| | |_| || (_| | (__|   <
|_____/ \___|_|    \_/ \___|_|     \__,_|\__|\__\__,_|\___|_|\_\
EOF
)
echo -e "$logo"
echo -e "\033[1;32;40m[*] Server attacks refer to malicious activities targeting servers, aimed at overwhelming the server by sending a large number of legitimate or illegitimate requests, thus exceeding its capacity and preventing it from providing normal services to legitimate users.\033[1;37;40m"

# Define file dictionary
declare -A files
files=(
      ["1"]="ddos/Server_attack/Cache_Server_Attack.py"
      ["2"]="ddos/Server_attack/Minecraft_server_DDoS.py"
      ["3"]="ddos/Server_attack/translation_server_ddos.py"
)

# Create a menu using whiptail
while true; do
      choice=$(whiptail --title "Server Attack Types" --menu "Server attacks refer to malicious activities targeting servers, aimed at overwhelming the server by sending a large number of legitimate or illegitimate requests, thus exceeding its capacity and preventing it from providing normal services to legitimate users.\n\nPlease select an attack type:" 35 78 20 \
      "1" "Cache Server Attack" \
      "2" "Minecraft Server DDoS" \
      "3" "Translation Server DDoS" \
      "0" "Back" \
      3>&1 1>&2 2>&3)

      if [[ $? -eq 0 ]]; then
          if [[ "$choice" == "0" ]]; then
              echo "Operation cancelled."
              break
          else
              python3 "${files[$choice]}"
              break
          fi
      else
          echo "Operation cancelled."
          break
      fi
done
